package bookExercise;

import java.util.*;

public class E1002{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		long[] list = new long[10000000];
		int length ;

		while(input.hasNext()){
			length = input.nextInt();
			for(int i=0; i<length; ++i)
			{
				list[i] = input.nextLong();
			}
			Arrays.sort(list, 0, length);
			long mode = list[0];
			long maxTime = 0;
			long tempMaxTime = 0;
			int i;
			int maxIndex = 0;
		    for(i=0; i<length; ++i)
		    {
		    	if(list[i] == list[maxIndex])
		    		tempMaxTime++;
		    	else
		    	{
		    		if(tempMaxTime>maxTime)
		    		{
		    			mode = list[maxIndex];
		    			maxTime = tempMaxTime;
		    		}
		    		tempMaxTime = 1;
		    		maxIndex = i;
		    	}
		    }
			
			System.out.println(mode);
			System.out.println(maxTime);
		}
		
 		
	}

}